package com.collection;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @author south wind
 * @version 1.0
 * @date 2025/4/2 20:15
 * @description 和Test04搭配使用
 */
public class Test04 {
    public static void main(String[] args) {
        //1.创建一个map集合
        Map<String,String> map = new HashMap<>();
        map.put("tom","CoreJava");
        map.put("John", "Oracle");
        map.put("Susan", "Oracle");
        map.put("Jerry", "JDBC");
        map.put("Jim", "Unix");
        map.put("Kevin", "JSP");
        map.put("Lucy", "JSP");
        System.out.println("------------");
        //2.新增一个老师Allen  教JDBC
        map.put("Allen","JDBC");
        System.out.println("------------");
        //3.Lucy改为教CoreJava
        for (Map.Entry<String, String> entry : map.entrySet()){
            if ("Lucy".equals(entry.getKey())){
                entry.setValue("CoreJava");
            }
        }
        System.out.println("------------");
        //4.遍历Map,输出所有老师以及课程
        for (Map.Entry<String, String> entry : map.entrySet()){
            System.out.println(entry.getKey()+"老师教"+entry.getValue());
        }
        System.out.println("------------");
        //5.利用Map，输出所有教JSP的老师
        for (Map.Entry<String, String> entry : map.entrySet()){
            if ("JSP".equals(entry.getValue())){
                System.out.println(entry.getKey()+"老师教"+entry.getValue());
            }
        }


    }
}
